import React from "react";
import Son2 from "./Son2";
// 1.引入 PropTypes
import PropTypes from 'prop-types'

export default class Son1 extends React.Component {
  // 2. 组件类上挂载 propTypes 对象,对父组件传的值进行类型限定
  static propTypes = {
    name: PropTypes.string.isRequired,
    age: PropTypes.number.isRequired
  }
  render() {
    return (
      <div>
        {/* 单个插槽: this.props.children */}
        {/* 多个插槽: this.props.children[0] */}
        {this.props.children[0]}
        <Son2 />
        名字:{this.props.name}
        年龄:{this.props.age}

        {this.props.children[1]}
      </div>
    );
  }
}